package org.sn.jdish.dubbo.base;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.common.logger.Logger;
import com.alibaba.dubbo.common.logger.LoggerFactory;

import org.springframework.scheduling.config.CronTask;

@Component
@Lazy(value = false)
@EnableScheduling
public class AppScheduler implements SchedulingConfigurer {

	private static final Logger logger = LoggerFactory.getLogger(SchedulingConfigurer.class);

	public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
		List<CronTask> cronTasks = new ArrayList<CronTask>();
		cronTasks.add(new CronTask(new Runnable() {

			public void run() {
				logger.info("this a task!");
			}

		}, "0/10 * * * * ? "));
		scheduledTaskRegistrar.setCronTasksList(cronTasks);
	}

}
